-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: stubs for reshape, ops, ops_dispatch, hashing #40455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jbrockmendel generally lgtm
pandas/_libs/hashing.pyi
Outdated
def hash_object_array( | ||
arr: np.ndarray, # np.ndarray[object] | ||
key: str, | ||
encoding: str = "utf8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encoding: str = "utf8", | |
encoding: str = ..., |
pandas/_libs/ops_dispatch.pyi
Outdated
REVERSED_NAMES: dict[str, str] | ||
UFUNC_ALIASES: dict[str, str] | ||
DISPATCHED_UFUNCS: set[str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not accessed from python code.
so I don't think is covered by https://github.com/python/typeshed/blob/master/CONTRIBUTING.md#what-to-include
and from https://github.com/python/typeshed/blob/master/CONTRIBUTING.md#conventions
The general rule is that they should be as concise as possible.
so I think we should perhaps not include these.
once we activate ignore_missing_imports = False
, we'll know if we missed anything.
side note: for the stub files we could consider activating more of the strictness flags for incomplete function annotations and dynamic typing etc.
DISPATCHED_UFUNCS: set[str] | ||
|
||
def maybe_dispatch_ufunc_to_dunder_op( | ||
self, ufunc: np.ufunc, method: str, *inputs, **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe type self, since function is not a method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will take some tracking down, since it is called via arraylike.array_ufunc, which doesnt type self
pandas/_libs/ops.pyi
Outdated
|
||
def maybe_convert_bool( | ||
arr: np.ndarray, # np.ndarray[object] | ||
true_values=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true_values=None, | |
true_values=..., |
pandas/_libs/ops.pyi
Outdated
def maybe_convert_bool( | ||
arr: np.ndarray, # np.ndarray[object] | ||
true_values=None, | ||
false_values=None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false_values=None | |
false_values=... |
pandas/_libs/ops.pyi
Outdated
binop = Callable[[Any, Any], Any] | ||
bool_op = Callable[[Any, Any], bool] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from https://github.com/python/typeshed/blob/master/CONTRIBUTING.md#conventions
Type variables and aliases you introduce purely for legibility reasons should be prefixed with an underscore to make it obvious to the reader they are not part of the stubbed API.
we normally capitalize as well
IIUC The pyright stubs are mainly for the public api. for our internal consistency checking , pandas._libs includes functions that we use internally, so manually curated is probably best for now. |
Will update per suggestions.
Following the dev call last month (two months ago?) about stubs I looked over pyright's stubs for _libs and found them not-totally-accurate (mostly Timestamp/Timedelta IIRC), so I plan to do all of these manually. |
Thanks @jbrockmendel |
manually curated, extra specificity in comments it is supported directly